/*
 * Copyright 2013 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.googlecode.gwtdb.client.indexeddb;

import com.googlecode.gwtdb.client.indexeddb.exception.IDBDOMException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBDataCloneException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBDataErrorException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBInvalidStateException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBNotFoundException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBReadOnlyException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBTransactionInactiveException;
import com.googlecode.gwtdb.client.indexeddb.exception.IDBTypeException;

public interface IDBObjectStore<K, V> {
  public IDBRequest add(V value, Object optionalKey) throws IDBDOMException;

  public IDBRequest clear() throws IDBDOMException;

  public IDBRequest count() throws IDBDOMException;

  public IDBRequest count(IDBKey<K> key) throws IDBDOMException;

  public IDBRequest count(IDBKeyRange<K> keyRange) throws IDBDOMException;

  public IDBIndex createIndex(String name, String keyPath, /* TODO */Object optionalIndexParameters);

  public IDBRequest delete(IDBKey<K> key);

  public IDBRequest delete(IDBKeyRange<K> keyRange);

  public void deleteIndex(String indexName) throws IDBInvalidStateException, IDBNotFoundException;

  public IDBRequest get(IDBKey<K> key) throws IDBTransactionInactiveException,
      IDBDataErrorException,
      IDBInvalidStateException;

  public IDBRequest get(IDBKeyRange<K> keyRange) throws IDBTransactionInactiveException,
      IDBDataErrorException, IDBInvalidStateException;

  public IDBIndex getIndex(String name) throws IDBInvalidStateException, IDBNotFoundException;
  
  public IDBRequest openCursor(IDBKeyRange<K> range, IDBCursorDirection direction)
      throws IDBTransactionInactiveException, IDBDataErrorException, IDBInvalidStateException,
      IDBTypeException;

  public IDBRequest put(/* TODO */V value, /* TODO */IDBKey<K> key)
      throws IDBReadOnlyException,
      IDBTransactionInactiveException, IDBDataErrorException, IDBInvalidStateException,
      IDBDataCloneException;

}
